home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / _PD_TOOLS_BEZ.pdrx next >
Text File  |  1992-06-15  |  2KB  |  74 lines

  1. /*
  2. BEZIER TOOL
  3.  
  4.     Click down at the position of the control point.
  5.     Drag tangent point to desired position and release.
  6.     Hit ESC to terminate an open curve.
  7.  
  8. Modifiers:
  9.     Double Clicking will bring up a requester which allows you to
  10.     create a multi-sided polygon.
  11.     
  12.     Hold CONTROL and click & release mouse over an existing end
  13.     point to create closed curve or join to existing curve.
  14.     SHIFT - constrains Bezier to be a straight line.
  15.     ALT   - constrains control points to be in a 45° direction
  16.             from the previous control point.
  17. */
  18.  
  19. msg = PDSetup.rexx(2,0)
  20. units = getclip(pds_units)
  21. if msg ~= 1 then exit_msg(msg)
  22.  
  23. numeric digits 8
  24.  
  25. pi2 = 6.28318
  26. cr = '0a'x
  27.  
  28. sides = getclip(pduserpolysides)
  29. radius = getclip(pduspolyradius)
  30. if sides = '' then sides = 5
  31. if radius = '' then radius = 1
  32.  
  33. if units > 2 then radius = pdm_ConvertUnits(1, units, radius)
  34.  
  35. sides = pdm_GetForm("Enter number of sides",8, "Sides:"sides || cr"Radius:"radius)
  36. if sides = '' then exit_msg()
  37.  
  38. parse var sides nsides '0a'x radius
  39. if ~(datatype(nsides, n) & datatype(radius, n)) then exit_msg("Invalid Entry")
  40. if nsides < 3 then exit_msg("A polygon must have at least 3 sides")
  41. if radius < 0 then exit_msg("Invalid entry")
  42. if units > 2 then radius = pdm_ConvertUnits(units, 1, radius)
  43.  
  44. call setclip(pduserpolysides, nsides)
  45. call setclip(pduspolyradius, radius)
  46.  
  47. ang = pi2 / nsides
  48. posn = pdm_clickellipse("Click at position for polygon..",radius,radius)
  49. if posn = '' then exit_msg()
  50.  
  51. call pdm_initplot(word(posn,1),word(posn,2),1,1,0)
  52. call pdm_ShowStatus("Working..")
  53.  
  54. do steps = 0 to nsides - 1
  55.    theta = ang * steps
  56.    x = cos(theta) * radius
  57.    y = sin(theta) * radius
  58.    call pdm_plotline(x" "y)
  59. end
  60.  
  61. call pdm_ClosePlot()
  62. exit_msg()
  63.  
  64. exit_msg: procedure expose units
  65. do
  66.     parse arg message
  67.  
  68.     if message ~= '' then call pdm_Inform(1,message,)
  69.     call pdm_ClearStatus()
  70.     call pdm_SetUnits(units)
  71.     call pdm_AutoUpdate(1)
  72.     exit
  73. end
  74.